/*
 * TepcoMeter:TepcoMeterSQLiteOpenHelper.java
 * Copyright © 2011 ho9ho9 All Rights Reserved.
 */
package com.ho9ho9.tepcometer.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * TepcoMeterSQLiteOpenHelperクラス.
 * @author ho9ho9
 */
public class TepcoMeterSQLiteOpenHelper extends SQLiteOpenHelper {

	private static final int DB_VERSION = 1;
	private static final String DB_NAME = "tepcometer.db";
	
	public TepcoMeterSQLiteOpenHelper(Context context) {
		super(context, DB_NAME, null, DB_VERSION);
	}

	/**
	 * {@inheritdoc}
	 */
	@Override
	public void onCreate(SQLiteDatabase db) {
		// テーブル作成
		db.execSQL(
				"create table if not exists " + TepcoMeterDao.WattInfo.TABLE_NAME + "("
				+ TepcoMeterDao.WattInfo.COL_WATT_DAY + " text primary key"
				+ "," + TepcoMeterDao.WattInfo.COL_CAPABILITY + " integer"
				+ "," + TepcoMeterDao.WattInfo.COL_UPDATED + " text"
				+ "," + TepcoMeterDao.WattInfo.COL_INSERT_DATE + " text"
				+ ");"
			);
		db.execSQL(
				"create table if not exists " + TepcoMeterDao.WattHours.TABLE_NAME + "("
				+ TepcoMeterDao.WattHours.COL_WATT_DAY + " text"
				+ "," + TepcoMeterDao.WattHours.COL_WATT_HOUR + " integer"
				+ "," + TepcoMeterDao.WattHours.COL_WATT_VALUE + " integer"
				+ ",primary key (" + TepcoMeterDao.WattHours.COL_WATT_DAY + "," + TepcoMeterDao.WattHours.COL_WATT_HOUR + ")"
				+ ");"
			);
	}

	/**
	 * {@inheritdoc}
	 */
	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
	}

}
